# Contributor: Ramanathan Sivagurunathan <ramzthecoder@gmail.com>
# Maintainer: Ramanathan Sivagurunathan <ramzthecoder@gmail.com>
pkgname=metricbeat
pkgver=7.13.1
pkgrel=6
pkgdesc="MetricBeat - Lightweight shipper for system and service statistics"
pkgusers="root"
url="https://www.elastic.co/products/beats"
# riscv64: https://github.com/elastic/go-concert/issues/51
arch="all !aarch64 !armhf !armv7 !riscv64"
license="Apache-2.0"
makedepends="go"
subpackages="$pkgname-openrc"
source="beats-$pkgver.tar.gz::https://github.com/elastic/beats/archive/v$pkgver.tar.gz
	metricbeat.initd
	metricbeat.confd
	metricbeat.yml
	"

builddir="$srcdir/beats-$pkgver"

export GOPATH="$srcdir/go"
export GOCACHE="$srcdir/go-build"
export GOTEMPDIR="$srcdir/go"

export GOFLAGS="$GOFLAGS -modcacherw"

build() {
	mkdir -p bin
	go build -o bin/ -v github.com/elastic/beats/v7/metricbeat
}

check() {
	go test -v github.com/elastic/beats/v7/metricbeat
}

package() {
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -Dm644 "$srcdir/metricbeat.yml" "$pkgdir/etc/$pkgname/metricbeat.yml"
	install -Dm755 "bin/metricbeat" "$pkgdir/usr/bin/metricbeat"
}

sha512sums="
25b3b0f7dc27777b5cb934163291060a0dbdeadc2b64e36913ff56de57d8b25578db2fda7d093c4041bf9a04776c970e039402f9c0022cca0cf1cd045fc257c0  beats-7.13.1.tar.gz
a846db44732077c38fd0699592ad27371af75ee8a53419c79197c4e5d727e1745c5145ebefd21073304cb624c5947686626f693e87406b122892f99cebe38f5b  metricbeat.initd
91fad211c1ac8b3bb97848f1ff97f7e708cfd100b174ae1839c4dd60d501cd8b7b4e9f0f4dbb936134c4ef19595bf39c53b256990f08f003c3e88893e0c94212  metricbeat.confd
b05e083c2ea2337cebd650f2898385ff40fb7f4fe2d7d46109cec3e960d80566129756e8a45e71ed53ec40c33539295453d363feafb60caec8747ae8d09f9124  metricbeat.yml
"
